{% extends 'easydisAPSBundle::base_template.html.twig' %}

{% block stylesheets %}
    <link rel="stylesheet" href="{{ asset('bundles/easydisAPS/css/css-template/colorpicker.css') }}" />
    <link rel="stylesheet" href="{{ asset('bundles/easydisAPS/css/css-template/uniform.css') }}" />
    <link rel="stylesheet" href="{{ asset('bundles/easydisAPS/css/css-template/select2.css') }}" />
    <link rel="stylesheet" href="{{ asset('bundles/easydisAPS/smoothness/jquery-ui-1.10.3.custom.css') }}" />
{% endblock %}
    
{% block scripts %}
    <script src="{{ asset('bundles/easydisAPS/js-template/bootstrap.min.js') }}"></script>
    <script src="{{ asset('bundles/easydisAPS/js-template/bootstrap-colorpicker.js') }}"></script>
    <script src="{{ asset('bundles/easydisAPS/js-template/jquery.uniform.js') }}"></script>
    <script src="{{ asset('bundles/easydisAPS/js-template/select2.min.js') }}"></script>
    <script src="{{ asset('bundles/easydisAPS/js-template/maruti.js') }}"></script>
    <script src="{{ asset('bundles/easydisAPS/js-template/maruti.form_common.js') }}"></script>
    <script type="text/javascript" src="{{ asset('bundles/easydisAPS/js/jquery-1.10.2.min.js') }}"></script>
    <script src="{{ asset('bundles/easydisAPS/smoothness/jquery-ui-1.10.3.custom.js') }}"></script>
    <script type="text/javascript" src="{{ asset('bundles/easydisAPS/js/datepickerFR.js') }}"></script>
    
    
    <script>
        
        $(function(){
            $('#date').datepicker();
            $('#easydis_apsbundle_planifier_date').datepicker();
        });
        
    </script>
{% endblock %}
    
{% block style %}
    
	table {
		overflow:hidden;
		border:1px solid #d3d3d3;
		background:#fefefe;
		width:100%;
		/*margin:5% auto 0;*/
		-moz-border-radius:5px; /* FF1+ */
		-webkit-border-radius:5px; /* Saf3-4 */
		border-radius:5px;
		-moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
		-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
	}
	
	th {padding:18px 28px 18px; text-align:center; }
        
        td {padding:5px 5px 5px; text-align:center; }
	
	th {padding-top:18px; text-shadow: 1px 1px 1px #fff; background:#e8eaeb; color: #000;}
	
	td {border-top:1px solid #e0e0e0; border-right:1px solid #e0e0e0;}
	
	tr.odd-row td {background:#f6f6f6;}
	
	td.first, th.first {text-align:left}
	
	td.last {border-right:none;}
	

	/*
        td {
		background: -moz-linear-gradient(100% 25% 90deg, #fefefe, #f9f9f9);
		background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f9f9f9), to(#fefefe));
	}*/
	
	tr.odd-row td {
		background: -moz-linear-gradient(100% 25% 90deg, #f6f6f6, #f1f1f1);
		background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f1f1f1), to(#f6f6f6));
	}
	
	th {
		background: -moz-linear-gradient(100% 20% 90deg, #e8eaeb, #ededed);
		background: -webkit-gradient(linear, 0% 0%, 0% 20%, from(#ededed), to(#e8eaeb));
	}
	

	
	tr:first-child th.first {
		-moz-border-radius-topleft:5px;
		-webkit-border-top-left-radius:5px; /* Saf3-4 */
	}
	
	tr:first-child th.last {
		-moz-border-radius-topright:5px;
		-webkit-border-top-right-radius:5px; /* Saf3-4 */
	}
	
	tr:last-child td.first {
		-moz-border-radius-bottomleft:5px;
		-webkit-border-bottom-left-radius:5px; /* Saf3-4 */
	}
	
	tr:last-child td.last {
		-moz-border-radius-bottomright:5px;
		-webkit-border-bottom-right-radius:5px; /* Saf3-4 */
	}
        
        .larger { 
            width: 500px;
        }
        
        td.cat {
            background-color: #e7eaeb;
            font-weight: bold;
            color: #000;
        }
        
        .select_planning {
            width : 8em;
            margin: 0 0 0 0;
        }
        
{% endblock %}


    
{% block contenu %}
    
{% for flashMessage in app.session.flashbag.get('notice') %}
		{% if flashMessage %}
			<div class="notice">
				{{ flashMessage }}
				<br/><br/>
			</div>
		{% endif %}
{% endfor %}
<div class="row-fluid">
    <div class="span6">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                        <i class="icon-plus"></i>
                </span>
                <h5>Changement de date</h5>
            </div>
            <div class="widget-content">
               <form id="madate" name="date" method="post" action="{{ path('easydisAPSBundle_redirect_planning', {'mode':'modif_unit','gs': gs.id, 'idsal': salarie.id, 'date':dateDebut}) }}">
                     <span>Modification de la date :</span>
                    <input type="input" name="date" id="date" size="10" readonly="readonly" style="width:100px;"/>
                    <button type="submit" class="btn-info" >Valider</button>
               </form>
            </div>
        </div>
    </div>
    <div class="span6">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                        <i class="icon-plus"></i>
                </span>
                <h5>Changement de vision</h5>
            </div>
            <div class="widget-content">
               <form id="madate" name="date" method="post" action="{{ path('easydisAPSBundle_redirect_planning', {'mode':'modif_unit','gs': gs.id, 'idsal': salarie.id, 'date':dateDebut}) }}">
                    <span>Modification du groupe de service :</span>
                    <select name="idgs" size="1">
                        <option></option>
                        {% for gs in list_gs %}
                            <option value="{{ gs.id }}">{{ gs.lib }}</option>
                        {% endfor %}
                    </select>
                    <button type="submit" class="btn-info" style="vertical-align:top;">Valider</button>
               </form>
            </div>
        </div>
    </div>
</div>
        
<div class="row-fluid">
    <div class="span12">
            <h4>Vision : <a href="{{ path('easydisAPSBundle_planning_view', {'gs': gs.id, 'date':dateDebut}) }}">{{ gs.lib }}</a></h4>
        <div class="widget-box">
          <div class="widget-title">
             <span class="icon"><i class="icon-th"></i></span> 
             <h5>Planning de : {{ salarie.nom }} {{ salarie.prenom }} [Service: {{salarie.section.service.lib}}]</h5>
          </div>
          <div class="widget-content nopadding">
            <table>
                <thead>
                <tr>
                    <th class="larger">Semaine {{ num_semaine }}</th>
                    <th>Lundi <i>{{ tabdates[0] }}</i></th>
                    <th>Mardi <i>{{ tabdates[1] }}</i></th>
                    <th>Mercredi <i>{{ tabdates[2] }}</i></th>
                    <th>Jeudi <i>{{ tabdates[3] }}</i></th>
                    <th>Vendredi <i>{{ tabdates[4] }}</i></th>
                    <th>Samedi <i>{{ tabdates[5] }}</i></th>
                    <th>Dimanche <i>{{ tabdates[6] }}</i></th>
                </tr>
                </thead>
                <tbody> 
                {% for affect in planning %}
                    {% if affect[0][0] is not null %}
                    <tr>
                        <td class="larger" rowspan="2"><h5>{{ affect[0][0][0] }}</h5></td>
                        
                        {% set strs = affect[0][1]|split('/')%}
                        {% set colors = affect[0][3]|split('/')%}
                        <td><span style="color: {{ colors[0] }}">{{ strs[0] }}</span>{% if strs|length > 1 %} <span style="color: {{ colors[1] }}">{{ strs[1] }}</span> {% endif %}</td>
                        
                        {% set strs = affect[1][1]|split('/')%}
                        {% set colors = affect[1][3]|split('/')%}
                        <td><span style="color: {{ colors[0] }}">{{ strs[0] }}</span>{% if strs|length > 1 %} <span style="color: {{ colors[1] }}">{{ strs[1] }}</span> {% endif %}</td>
                        
                        {% set strs = affect[2][1]|split('/')%}
                        {% set colors = affect[2][3]|split('/')%}
                        <td><span style="color: {{ colors[0] }}">{{ strs[0] }}</span>{% if strs|length > 1 %} <span style="color: {{ colors[1] }}">{{ strs[1] }}</span> {% endif %}</td>
                        
                        {% set strs = affect[3][1]|split('/')%}
                        {% set colors = affect[3][3]|split('/')%}
                        <td><span style="color: {{ colors[0] }}">{{ strs[0] }}</span>{% if strs|length > 1 %} <span style="color: {{ colors[1] }}">{{ strs[1] }}</span> {% endif %}</td>
                        
                        {% set strs = affect[4][1]|split('/')%}
                        {% set colors = affect[4][3]|split('/')%}
                        <td><span style="color: {{ colors[0] }}">{{ strs[0] }}</span>{% if strs|length > 1 %} <span style="color: {{ colors[1] }}">{{ strs[1] }}</span> {% endif %}</td>
                        
                        {% set strs = affect[5][1]|split('/')%}
                        {% set colors = affect[5][3]|split('/')%}
                        <td><span style="color: {{ colors[0] }}">{{ strs[0] }}</span>{% if strs|length > 1 %} <span style="color: {{ colors[1] }}">{{ strs[1] }}</span> {% endif %}</td>
                        
                        {% set strs = affect[6][1]|split('/')%}
                        {% set colors = affect[6][3]|split('/')%}
                        <td><span style="color: {{ colors[0] }}">{{ strs[0] }}</span>{% if strs|length > 1 %} <span style="color: {{ colors[1] }}">{{ strs[1] }}</span> {% endif %}</td>
                    </tr>
                    <tr>
                        <td>{{ affect[0][2] }}</td>
                        <td>{{ affect[1][2] }}</td>
                        <td>{{ affect[2][2] }}</td>
                        <td>{{ affect[3][2] }}</td>
                        <td>{{ affect[4][2] }}</td>
                        <td>{{ affect[5][2] }}</td>
                        <td>{{ affect[6][2] }}</td>
                    </tr>
                    {% endif %}
                {% endfor %}
                 <form action="{{ path('easydisAPSBundle_planning_update_salarie') }}" method="post">   
                 <tr>
                    <td class="larger" rowspan="2">Modification :</td>
                    {% set i = 1 %}
                    {% for i in 1..7 %}
                        <td>
                        <select name="poste_{{i}}" size="1" class="select_planning">
                            <option></option>
                            {% for poste in list_postes %}
                                <option value="{{ poste.id }}">{{ poste.lib }}</option>
                            {% endfor %}
                        </select>
                        </td>
                    {% endfor %}
                </tr>
                <tr>
                    {% for i in 1..7 %}
                        <td>
                        <select name="ph_{{i}}" size="1" class="select_planning">
                            <option></option>
                            {% for ph in list_ph %}
                                <option value="{{ ph.id }}">{{ ph.lib }}</option>
                            {% endfor %}
                        </select>
                        </td>
                    {% endfor %}
                </tr>
                </tbody>
            </table>
          <br/>
          <input type="hidden" name="dateDebut" value="{{ dateDebut }}"/>
          <input type="hidden" name="gs" value="{{ gs.id }}"/>
          <input type="hidden" name="idsal" value="{{ salarie.id }}"/>
          <input type="submit" value="Confirmer" class="btn btn-warning" style="margin-left: 35px; margin-right: 10px;"/> <span style="color: #f89405; font-weight: bold;">Attention l'envoi du formulaire écrasera les données éxistantes. </span>
          </form>
          <br/><br/>
          </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div class="span6">
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                        <i class="icon-plus"></i>
                </span>
                <h5>Gestion des multipostes</h5>
            </div>
            <div class="widget-content">
                <form action="{{ path('easydisAPSBundle_planning_add_planifier', {'idsal':salarie.id, 'gs':gs.id}) }}" method="post" {{ form_enctype(form) }} class="form-horizontal">
                    {# Les erreurs générales du formulaire. #}
                    {{ form_errors(form) }}

                    <div class="control-group">
                        <label class="control-label">Date :</label>
                        <div class="controls">
                            {{ form_errors(form.date) }}
                            {{ form_widget(form.date, { 'attr': {'name': 'dateplan'} }) }}
                        </div>
                        <label class="control-label">Plage horaire :</label>
                        <div class="controls">
                            {{ form_errors(form.plagehoraire) }}
                            {{ form_widget(form.plagehoraire) }}
                        </div>
                        <label class="control-label">Poste :</label>
                        <div class="controls">
                            {{ form_errors(form.poste) }}
                            {{ form_widget(form.poste) }}
                        </div>
                    </div>
                      
                    {# Génération des champs pas encore écrits.
                       Dans cet exemple, ce serait « date », « auteur » et « publication »,
                       mais aussi le champ CSRF (géré automatiquement par Symfony !)
                       et tous les champs cachés (type « hidden »). #}

                    {{ form_rest(form) }}
                        
                    <div class="form-actions">
                        <button type="submit" class="btn btn-success">Enregistrer</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}